<template>
  <div class="home"></div>
</template>

<script>
// for (var i = 1; i <= 5; i++) {
//   (function (i) {
//     setTimeout(function timer() {
//       console.log(i); //隔一秒依次打印出1,2,3,4,5
//     }, i * 1000);
//   })(i);
// }
// console.log(i); //6
console.log("_______________________________");
var obj1 = { a: 1, b: 2, c: 3, d: { e: 4 } };
var obj2 = { ...obj1 };
obj1.a = 2;
obj1.d.e = 5;
console.log(obj2); // { a: 1, b: 2, c: 3, d: { e: 5 } }
console.log("_______________________________");
setTimeout(function () {
  console.log(1);
}, 0);
new Promise(function (resolve) {
  console.log(2);
  resolve();
  console.log(3);
}).then(function () {
  console.log(4);
});
// 打印顺序依次为：2,3,4,1
console.log("_______________________________");
const arr = [12, 24, 37, 24, 49, 55, 68]; //去重
let newArr = arr.filter((item, index, Array) => {
  return Array.indexOf(item) == index;
});
console.log(newArr);
let newArr1=[...new Set(arr)]
console.log(newArr1);
</script>
